import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-07-31
 * 11:08
 */
public class Test {
    public static void main(String[] args) {

    }
    public boolean IsPopOrder (int[] pushV, int[] popV) {
        // write code here
        int j=0;
        Stack<Integer> stack=new Stack<>();
        for(int i=0;i<pushV.length;i++){
            stack.push(pushV[i]);

            while(!stack.isEmpty()&&j<popV.length&&stack.peek()==popV[j]){
                stack.pop();
                j++;
            }
        }

        return stack.isEmpty();
    }
}
